﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace ZGEDrySaltery.Web.offer
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int OFFERID=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(OFFERID);
				}
			}
		}
			
	private void ShowInfo(int OFFERID)
	{
		ZGEDrySaltery.BLL.offer bll=new ZGEDrySaltery.BLL.offer();
		ZGEDrySaltery.Model.offer model=bll.GetModel(OFFERID);
		this.lblOFFERID.Text=model.OFFERID.ToString();
		this.txtCOMPANYID.Text=model.COMPANYID.ToString();
		this.txtUSERID.Text=model.USERID.ToString();
		this.txtUSERNAME.Text=model.USERNAME;
		this.txtREALNAME.Text=model.REALNAME;
		this.txtTITLE.Text=model.TITLE;
		this.txtUNIT.Text=model.UNIT;
		this.txtSPECIFICATIONSSTR.Text=model.SPECIFICATIONSSTR;
		this.txtVIPPRICE.Text=model.VIPPRICE.ToString();
		this.txtMARKETPRICE.Text=model.MARKETPRICE.ToString();
		this.txtMINPRICE.Text=model.MINPRICE.ToString();
		this.txtPIFAPRICE.Text=model.PIFAPRICE.ToString();
		this.txtPCID.Text=model.PCID.ToString();
		this.txtINTRO.Text=model.INTRO;
		this.txtAREA.Text=model.AREA;
		this.txtRECOMMEND.Text=model.RECOMMEND.ToString();
		this.txtSORT.Text=model.SORT.ToString();
		this.txtIMAGES.Text=model.IMAGES;
		this.txtINVENTORYCOUNT.Text=model.INVENTORYCOUNT.ToString();
		this.txtTRADETOTAL.Text=model.TRADETOTAL.ToString();
		this.txtSTATE.Text=model.STATE.ToString();
		this.txtMEMO.Text=model.MEMO;
		this.txtINSERTTIME.Text=model.INSERTTIME.ToString();
		this.txtMODIFYTIME.Text=model.MODIFYTIME.ToString();
		this.txtF1.Text=model.F1;
		this.txtF2.Text=model.F2;
		this.txtF3.Text=model.F3;
		this.txtF4.Text=model.F4;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(!PageValidate.IsNumber(txtCOMPANYID.Text))
			{
				strErr+="COMPANYID格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtUSERID.Text))
			{
				strErr+="USERID格式错误！\\n";	
			}
			if(this.txtUSERNAME.Text.Trim().Length==0)
			{
				strErr+="USERNAME不能为空！\\n";	
			}
			if(this.txtREALNAME.Text.Trim().Length==0)
			{
				strErr+="REALNAME不能为空！\\n";	
			}
			if(this.txtTITLE.Text.Trim().Length==0)
			{
				strErr+="TITLE不能为空！\\n";	
			}
			if(this.txtUNIT.Text.Trim().Length==0)
			{
				strErr+="UNIT不能为空！\\n";	
			}
			if(this.txtSPECIFICATIONSSTR.Text.Trim().Length==0)
			{
				strErr+="SPECIFICATIONSSTR不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtVIPPRICE.Text))
			{
				strErr+="VIPPRICE格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtMARKETPRICE.Text))
			{
				strErr+="MARKETPRICE格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtMINPRICE.Text))
			{
				strErr+="MINPRICE格式错误！\\n";	
			}
			if(!PageValidate.IsDecimal(txtPIFAPRICE.Text))
			{
				strErr+="PIFAPRICE格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtPCID.Text))
			{
				strErr+="PCID格式错误！\\n";	
			}
			if(this.txtINTRO.Text.Trim().Length==0)
			{
				strErr+="INTRO不能为空！\\n";	
			}
			if(this.txtAREA.Text.Trim().Length==0)
			{
				strErr+="AREA不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtRECOMMEND.Text))
			{
				strErr+="RECOMMEND格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtSORT.Text))
			{
				strErr+="SORT格式错误！\\n";	
			}
			if(this.txtIMAGES.Text.Trim().Length==0)
			{
				strErr+="IMAGES不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtINVENTORYCOUNT.Text))
			{
				strErr+="INVENTORYCOUNT格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtTRADETOTAL.Text))
			{
				strErr+="TRADETOTAL格式错误！\\n";	
			}
			if(!PageValidate.IsNumber(txtSTATE.Text))
			{
				strErr+="STATE格式错误！\\n";	
			}
			if(this.txtMEMO.Text.Trim().Length==0)
			{
				strErr+="MEMO不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtINSERTTIME.Text))
			{
				strErr+="INSERTTIME格式错误！\\n";	
			}
			if(!PageValidate.IsDateTime(txtMODIFYTIME.Text))
			{
				strErr+="MODIFYTIME格式错误！\\n";	
			}
			if(this.txtF1.Text.Trim().Length==0)
			{
				strErr+="F1不能为空！\\n";	
			}
			if(this.txtF2.Text.Trim().Length==0)
			{
				strErr+="F2不能为空！\\n";	
			}
			if(this.txtF3.Text.Trim().Length==0)
			{
				strErr+="F3不能为空！\\n";	
			}
			if(this.txtF4.Text.Trim().Length==0)
			{
				strErr+="F4不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int OFFERID=int.Parse(this.lblOFFERID.Text);
			int COMPANYID=int.Parse(this.txtCOMPANYID.Text);
			int USERID=int.Parse(this.txtUSERID.Text);
			string USERNAME=this.txtUSERNAME.Text;
			string REALNAME=this.txtREALNAME.Text;
			string TITLE=this.txtTITLE.Text;
			string UNIT=this.txtUNIT.Text;
			string SPECIFICATIONSSTR=this.txtSPECIFICATIONSSTR.Text;
			decimal VIPPRICE=decimal.Parse(this.txtVIPPRICE.Text);
			decimal MARKETPRICE=decimal.Parse(this.txtMARKETPRICE.Text);
			decimal MINPRICE=decimal.Parse(this.txtMINPRICE.Text);
			decimal PIFAPRICE=decimal.Parse(this.txtPIFAPRICE.Text);
			int PCID=int.Parse(this.txtPCID.Text);
			string INTRO=this.txtINTRO.Text;
			string AREA=this.txtAREA.Text;
			int RECOMMEND=int.Parse(this.txtRECOMMEND.Text);
			int SORT=int.Parse(this.txtSORT.Text);
			string IMAGES=this.txtIMAGES.Text;
			int INVENTORYCOUNT=int.Parse(this.txtINVENTORYCOUNT.Text);
			int TRADETOTAL=int.Parse(this.txtTRADETOTAL.Text);
			int STATE=int.Parse(this.txtSTATE.Text);
			string MEMO=this.txtMEMO.Text;
			DateTime INSERTTIME=DateTime.Parse(this.txtINSERTTIME.Text);
			DateTime MODIFYTIME=DateTime.Parse(this.txtMODIFYTIME.Text);
			string F1=this.txtF1.Text;
			string F2=this.txtF2.Text;
			string F3=this.txtF3.Text;
			string F4=this.txtF4.Text;


			ZGEDrySaltery.Model.offer model=new ZGEDrySaltery.Model.offer();
			model.OFFERID=OFFERID;
			model.COMPANYID=COMPANYID;
			model.USERID=USERID;
			model.USERNAME=USERNAME;
			model.REALNAME=REALNAME;
			model.TITLE=TITLE;
			model.UNIT=UNIT;
			model.SPECIFICATIONSSTR=SPECIFICATIONSSTR;
			model.VIPPRICE=VIPPRICE;
			model.MARKETPRICE=MARKETPRICE;
			model.MINPRICE=MINPRICE;
			model.PIFAPRICE=PIFAPRICE;
			model.PCID=PCID;
			model.INTRO=INTRO;
			model.AREA=AREA;
			model.RECOMMEND=RECOMMEND;
			model.SORT=SORT;
			model.IMAGES=IMAGES;
			model.INVENTORYCOUNT=INVENTORYCOUNT;
			model.TRADETOTAL=TRADETOTAL;
			model.STATE=STATE;
			model.MEMO=MEMO;
			model.INSERTTIME=INSERTTIME;
			model.MODIFYTIME=MODIFYTIME;
			model.F1=F1;
			model.F2=F2;
			model.F3=F3;
			model.F4=F4;

			ZGEDrySaltery.BLL.offer bll=new ZGEDrySaltery.BLL.offer();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
